package com.youyi.yyviewsdklibrary.picker.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import com.lkx.liandianqinew.R;
import com.youyi.yyviewsdklibrary.picker.contract.OnWheelChangedListener;
import java.util.ArrayList;
import java.util.List;

public abstract class BaseWheelLayout extends LinearLayout implements OnWheelChangedListener {
    private final List<WheelView> wheelViews = new ArrayList();

    /* access modifiers changed from: protected */
    public void onAttributeSet(Context context, AttributeSet attributeSet) {
    }

    /* access modifiers changed from: protected */
    public void onInit(Context context) {
    }

    @Override // com.youyi.yyviewsdklibrary.picker.contract.OnWheelChangedListener
    public void onWheelLoopFinished(WheelView wheelView) {
    }

    @Override // com.youyi.yyviewsdklibrary.picker.contract.OnWheelChangedListener
    public void onWheelScrollStateChanged(WheelView wheelView, int i) {
    }

    @Override // com.youyi.yyviewsdklibrary.picker.contract.OnWheelChangedListener
    public void onWheelScrolled(WheelView wheelView, int i) {
    }

    /* access modifiers changed from: protected */
    public abstract int provideLayoutRes();

    /* access modifiers changed from: protected */
    public abstract List<NumberWheelView> provideWheelViews();

    public BaseWheelLayout(Context context) {
        super(context);
        init(context, null, R.attr.WheelStyle, R.style.WheelDefault);
    }

    public BaseWheelLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        init(context, attributeSet, R.attr.WheelStyle, R.style.WheelDefault);
    }

    public BaseWheelLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        init(context, attributeSet, i, R.style.WheelDefault);
    }

    public BaseWheelLayout(Context context, AttributeSet attributeSet, int i, int i2) {
        super(context, attributeSet, i);
        init(context, attributeSet, i, i2);
    }

    private void init(Context context, AttributeSet attributeSet, int i, int i2) {
        setOrientation(1);
        inflate(context, provideLayoutRes(), this);
        onInit(context);
        this.wheelViews.clear();
        this.wheelViews.addAll(provideWheelViews());
        initAttrs(context, attributeSet, i, i2);
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setOnWheelChangedListener(this);
        }
    }

    private void initAttrs(Context context, AttributeSet attributeSet, int i, int i2) {
        float f = context.getResources().getDisplayMetrics().density;
        float f2 = context.getResources().getDisplayMetrics().scaledDensity;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.BaseWheelLayout, i, i2);
        setVisibleItemCount(obtainStyledAttributes.getInt(R.styleable.BaseWheelLayout_wheel_visibleItemCount, 5));
        setSameWidthEnabled(obtainStyledAttributes.getBoolean(R.styleable.BaseWheelLayout_wheel_sameWidthEnabled, false));
        setMaxWidthText(obtainStyledAttributes.getString(R.styleable.BaseWheelLayout_wheel_maxWidthText));
        setTextColor(obtainStyledAttributes.getColor(R.styleable.BaseWheelLayout_wheel_itemTextColor, -7829368));
        setSelectedTextColor(obtainStyledAttributes.getColor(R.styleable.BaseWheelLayout_wheel_itemTextColorSelected, -16777216));
        float f3 = f2 * 15.0f;
        setTextSize(obtainStyledAttributes.getDimension(R.styleable.BaseWheelLayout_wheel_itemTextSize, f3));
        setSelectedTextSize(obtainStyledAttributes.getDimension(R.styleable.BaseWheelLayout_wheel_itemTextSizeSelected, f3));
        setSelectedTextBold(obtainStyledAttributes.getBoolean(R.styleable.BaseWheelLayout_wheel_itemTextBoldSelected, false));
        setTextAlign(obtainStyledAttributes.getInt(R.styleable.BaseWheelLayout_wheel_itemTextAlign, 0));
        setItemSpace(obtainStyledAttributes.getDimensionPixelSize(R.styleable.BaseWheelLayout_wheel_itemSpace, (int) (20.0f * f)));
        setCyclicEnabled(obtainStyledAttributes.getBoolean(R.styleable.BaseWheelLayout_wheel_cyclicEnabled, false));
        setIndicatorEnabled(obtainStyledAttributes.getBoolean(R.styleable.BaseWheelLayout_wheel_indicatorEnabled, false));
        setIndicatorColor(obtainStyledAttributes.getColor(R.styleable.BaseWheelLayout_wheel_indicatorColor, -3552823));
        float f4 = f * 1.0f;
        setIndicatorSize(obtainStyledAttributes.getDimension(R.styleable.BaseWheelLayout_wheel_indicatorSize, f4));
        setCurvedIndicatorSpace(obtainStyledAttributes.getDimensionPixelSize(R.styleable.BaseWheelLayout_wheel_curvedIndicatorSpace, (int) f4));
        setCurtainEnabled(obtainStyledAttributes.getBoolean(R.styleable.BaseWheelLayout_wheel_curtainEnabled, false));
        setCurtainColor(obtainStyledAttributes.getColor(R.styleable.BaseWheelLayout_wheel_curtainColor, -1996488705));
        setCurtainCorner(obtainStyledAttributes.getInt(R.styleable.BaseWheelLayout_wheel_curtainCorner, 0));
        setCurtainRadius(obtainStyledAttributes.getDimension(R.styleable.BaseWheelLayout_wheel_curtainRadius, 0.0f));
        setAtmosphericEnabled(obtainStyledAttributes.getBoolean(R.styleable.BaseWheelLayout_wheel_atmosphericEnabled, false));
        setCurvedEnabled(obtainStyledAttributes.getBoolean(R.styleable.BaseWheelLayout_wheel_curvedEnabled, false));
        setCurvedMaxAngle(obtainStyledAttributes.getInteger(R.styleable.BaseWheelLayout_wheel_curvedMaxAngle, 90));
        obtainStyledAttributes.recycle();
        onAttributeSet(context, attributeSet);
    }

    public void setStyle(int i) {
        initAttrs(getContext(), null, R.attr.WheelStyle, i);
        requestLayout();
        invalidate();
    }

    public void setEnabled(boolean z) {
        super.setEnabled(z);
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setEnabled(z);
        }
    }

    public void setVisibleItemCount(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setVisibleItemCount(i);
        }
    }

    public void setItemSpace(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setItemSpace(i);
        }
    }

    public void setSameWidthEnabled(boolean z) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setSameWidthEnabled(z);
        }
    }

    public void setDefaultItemPosition(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setDefaultPosition(i);
        }
    }

    public void setCurtainEnabled(boolean z) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCurtainEnabled(z);
        }
    }

    public void setCurtainColor(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCurtainColor(i);
        }
    }

    public void setCurtainCorner(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCurtainCorner(i);
        }
    }

    public void setCurtainRadius(float f) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCurtainRadius(f);
        }
    }

    public void setAtmosphericEnabled(boolean z) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setAtmosphericEnabled(z);
        }
    }

    public void setCurvedEnabled(boolean z) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCurvedEnabled(z);
        }
    }

    public void setCurvedMaxAngle(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCurvedMaxAngle(i);
        }
    }

    public void setCurvedIndicatorSpace(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCurvedIndicatorSpace(i);
        }
    }

    public void setCyclicEnabled(boolean z) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setCyclicEnabled(z);
        }
    }

    public void setIndicatorEnabled(boolean z) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setIndicatorEnabled(z);
        }
    }

    public void setIndicatorSize(float f) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setIndicatorSize(f);
        }
    }

    public void setIndicatorColor(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setIndicatorColor(i);
        }
    }

    public void setMaxWidthText(String str) {
        if (!TextUtils.isEmpty(str)) {
            for (WheelView wheelView : this.wheelViews) {
                wheelView.setMaxWidthText(str);
            }
        }
    }

    public void setTextSize(float f) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setTextSize(f);
        }
    }

    public void setSelectedTextSize(float f) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setSelectedTextSize(f);
        }
    }

    public void setTextColor(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setTextColor(i);
        }
    }

    public void setSelectedTextColor(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setSelectedTextColor(i);
        }
    }

    public void setSelectedTextBold(boolean z) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setSelectedTextBold(z);
        }
    }

    public void setTextAlign(int i) {
        for (WheelView wheelView : this.wheelViews) {
            wheelView.setTextAlign(i);
        }
    }
}
